﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace H02
{
    class Program
    {
        static void Main(string[] args)
        {
            #region T1编程求解一元二次方程 ax2 + bx + c = 0
            void T1()
            {
                Console.WriteLine("T1.编程求解一元二次方程 ax2 + bx + c = 0");
                Console.Write("输入系数a:");
                double a = double.Parse(Console.ReadLine());
                Console.Write("输入系数b:");
                double b = double.Parse(Console.ReadLine());
                Console.Write("输入系数c:");
                double c = double.Parse(Console.ReadLine());
                double temp = Math.Sqrt(b * b - 4 * a * c);
                double x1 = (-b + temp) / (2 * a);
                double x2 = (-b - temp) / (2 * a);
                Console.WriteLine("方程的解x1={0},x2={1}", x1, x2);
            }

            #endregion

            #region T2使用StringBuilder来删除一个字符串中的所有空格
            void T2()
            {
                Console.WriteLine("T2.使用StringBuilder来删除一个字符串中的所有空格");
                StringBuilder sb = new StringBuilder();
                string str1 = "abc 123 def 456 ghi";
                Console.WriteLine($"{str1}");
                string[] strArray;
                strArray = str1.Split(' ');
                foreach (var str2 in strArray)
                {
                    sb.Append(str2);
                    //Console.WriteLine(str2);
                }
                string str = sb.ToString();
                Console.WriteLine($"{str}");

            }

            #endregion


            T1();
            Console.WriteLine();
            T2();
            Console.WriteLine();


            Console.ReadKey();
        }
    }
}
